home *** CD-ROM | disk | FTP | other *** search
- Path: news.mcs.net!usenet
- From: The Last Raptor <raptor@mcs.net>
- Newsgroups: comp.lang.c
- Subject: Re: Two strange C problems.
- Date: Sat, 13 Jan 1996 12:52:20 -0600
- Organization: J.C. Technical Services
- Message-ID: <30F7FF64.6148@mcs.net>
- References: <DKuJHw.Dsu@rci.ripco.com>
- NNTP-Posting-Host: raptor-1.isdn.mcs.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b5 (Win95; I)
-
- Martin Ambuhl wrote:
- >
- > cs102238@lux.latrobe.edu.au (Gregary John Boyles )
- > in <4cojb2$qog@lugb.latrobe.edu.au> wrote:
- >
- > > I have two C problems.
- >
- > And what are they? You have problems, all right. Are they C problems?
- > Maybe, but there is no way to tell when your code is all dos-isms. Just
- > to compile this junk required me to add the following at the beginning.
- > If it doesn't look like it does what you expect, no big deal. Your
- > non-standard functions, structs, and macros can be defined any way one
- > wants, as long as there are no syntax problems as a result. The
- > semantics are completely undefined.
- >
- > /* BEGINNING prologue */
- > #include <stdio.h>
- > typedef struct {
- > short screenheight, screenwidth;
- > } text_info;
- > typedef struct { /* warning: no members */
- > } *nodetypeptr;
- >
- > #define initialize(x)
- > #define cputs puts
- > #define cprintf printf
- > #define maxstring BUFSIZ
- > #define removelineends(x,y)
- > #define add(x,y,z)
- > #define gettextinfo(x)
- > #define getcolors(a,b,c,d)
- > #define _setcursortype(x)
- > #define clrscr()
- > #define textcolor(x)
- > #define textbackground(x)
- > #define gotoxy(x,y)
- > #define writescreenfull(a,b,c,d,e,f,g);
- > #define setpos(x,y)
- > #define displayhelp(x,y,z)
- > #define readstring(a,b,c,d,e)
- > #define searchstring()
- > #define empty(x) 0
- > #define remove(y) /* note: remove is a reserved
- > * identifier (see stdio) */
- > #define getch() getchar()
- > #define window(a,b,c,d)
- >
- > char line[maxstring], bottomline[maxstring];
- > enum {
- > LIGHTGRAY, BLACK, _NOCURSOR, _NORMCURSOR, space, escape, up, down,
- > pageup, pagedown, left, right, end_, home, search, help, nul
- > }; /* note: _Nxxx are reserved identifiers */
- >
- > /* END prologue */
- >
- > [snip - line after line of M$dog-isms]
- >
- > >This program should exit such that the screen is clear with the DOS
- > >prompt in the upper left corner, ...
- >
- > Why should it? C doesn't even have such a concept as "screen". If
- > your implementation provides such functions, learn to use them or call
- > their technical support, or pay someone to debug your crap.
- >
- > >..., but no, it exits with a short line
- > >of text on the first line and then the DOS prompt on the next
- > >line.I never(or rarely) have these sort of problems with Pascal so
- > >why do they continuously crop up with C.
- >
- > Your problems have NOTHING to do with C. If you can't tell the
- > difference, then go back to whatever you have confused with Pascal.
- >
- > >
- > >
- > > PROBLEM 2 :
- > >
- > > const escape=27; const cr=13; const bs=8;
- > >
- > > while (ch!=cr) { . . . }
- > >
- > > while (ch!=escape) { . . . }
- > >
- > > If I replace the 27 with \27' or the 13 with '\13' then these loops
- > > don't work i.e. an infinite loop results. WHY?
- >
- > Clever. You have worked out that octal and decimal are not the same.
- > Just a hint:
- > \13 == 11
- > \15 == 13
- > \27 == 23
- > \33 == 27
- >
- >
- > > Also if I want to do somthing like this : puts("\24 \25"); which
- > > should print the up and down arrows on the screen (ASCII 24 and
- > > 25), but no, it prints some other ASCII characters. As far as I can
- > > tell C has its own unique character table, at least for the control
- > > characters. WHY?
- >
- > The IBM-extended character set (_not_ ASCII) defines the Up arrow and
- > Down arrow as \30 == 24 and \31 == 25 (\24 == 20 is a paragraph sign.
- > \25 == 21 is a section sign). This has nothing to do with C (except for
- > the use of \ooo for octal chars), and nothing to do with ASCII. The
- > world is not defined by your PC-toy.
- >
- > > Sometimes I wonder whether some one needs to go back an rewrite the
- > > damn language so that it works sensibly and predictably like Pascal
- > > can be relied upon to do.
- >
- > Learning how to read would be a hell of a lot more useful. The only
- > thing here which does not work sensibly and predictably is your brain.
- >
- >
- > --
- > * Martin Ambuhl net: mambuhl@ripco.com
- > * Chicago, IL (USA)That was so nice of you Martin........
- Try a little patince next time or do you prefer being an ahole.
- --
- J.C. Technical Services The Last Raptor
- CNA\CNE on call 24 hours a day.
- Novell, SNA, Banyan and Windows NT.
- Your complete network solution provider.
-